//  @ Project : GagalPanen
//  @ File Name : watersprite.cpp
//  @ Date : 3/9/2011
//  @ Author : Irvan
//
//


#include "watersprite.hpp"
#include "spritesconstants.hpp"
#include "gamemaps.hpp"
#include "creatures.hpp"

WaterSprite::WaterSprite(GameInterface* game) :
    Sprite(game, SpritesConstants::waterSpriteStartLocationXCoordinate(),
                 SpritesConstants::waterSpriteStartLocationYCoordinate()) {
  //TODO
  return;
}

WaterSprite::WaterSprite(GameInterface* game, std::ifstream& is) :
    Sprite(game, is) {
}

void WaterSprite::save(std::ofstream& os) {
  Sprite::save(os);
}

WaterSprite::~WaterSprite() {}

void WaterSprite::resetPosition() {
  setLocation(
          game_->getMaps()->getField()->getCellAt(
          SpritesConstants::waterSpriteStartLocationXCoordinate(),
          SpritesConstants::waterSpriteStartLocationYCoordinate()));
  return;
}

bool WaterSprite::isImportant(Cell* cell) {
  if (!cell->isPlantable()) {
    return false;
  }
  PlantableCell* pc = (PlantableCell*) cell;
  if (pc->isBurning()) {
    return true;
  }
  if (game_->getCreatures()->getPlants()->containsPlantAt(pc)) {
    Plant* plant = game_->getCreatures()->getPlants()->getPlantAt(pc);
    return !plant->isDead() && !plant->isHarvestable() && !pc->isWatered();
  }
  return false;
}

SpriteType WaterSprite::getType() {
  return kWater;
}

std::string WaterSprite::getViewRep(Direction dir) {
  return SpritesConstants::getWaterSpriteRep(dir);
}

ActionType WaterSprite::getActionType() {
  return kActionWater;
}
